//
//  UserPunishmentCell.m
//  CheekiOS
//
//  Created by mac on 2017/6/23.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "UserPunishmentCell.h"

@interface UserPunishmentCell ()

@property (nonatomic, strong)UILabel *nameLab;
@property (nonatomic, strong)UILabel *sexAgehometownLab;
@property (nonatomic, strong)UILabel *whyLab;
@property (nonatomic, strong)UILabel *timeLab;

@end

@implementation UserPunishmentCell

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath*)indexPath{
    static NSString *UserPunishmentCellIdent = @"UserPunishmentCellIdent";
    UserPunishmentCell *cell = [tableView dequeueReusableCellWithIdentifier:UserPunishmentCellIdent];
    if (!cell) {
        cell = [[UserPunishmentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:UserPunishmentCellIdent];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;

}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.nameLab = [UILabel new];
        self.nameLab.font =FontP(17);
        self.nameLab.textColor = [UIColor blackColor];
        self.nameLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.nameLab];
        
        self.sexAgehometownLab = [UILabel new];
        self.sexAgehometownLab.font =FontP(15);
        self.sexAgehometownLab.textColor =RGB(200, 200, 200);
        self.sexAgehometownLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.sexAgehometownLab];
        
        self.whyLab = [UILabel new];
        self.whyLab.font =FontP(12);
        self.whyLab.textColor =ColorI(0xff2222);
        self.whyLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.whyLab];
        
        self.timeLab = [UILabel new];
        self.timeLab.font =FontP(12);
        self.timeLab.textColor =RGB(200, 200, 200);
        self.timeLab.textAlignment = NSTextAlignmentLeft;
        [self addSubview:self.timeLab];
        
    }
    
    return self;
}

-(void)setModel:(UserpunishmentListModel *)model{

    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(15);
        make.top.equalTo(self).offset(10);
        make.height.mas_equalTo(25);
    }];
    
    
    [self.sexAgehometownLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab.mas_right).offset(5);
        make.top.equalTo(self).offset(10);
        make.height.mas_equalTo(25);
    }];
    
    
    [self.whyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLab.mas_right).offset(5);
        make.top.equalTo(self.nameLab.mas_bottom).offset(5);
        make.height.mas_equalTo(25);
    }];
    
    
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-15);
        make.top.equalTo(self.whyLab.mas_bottom).offset(0);
        make.height.mas_equalTo(25);
    }];
    
    
    self.nameLab.text = model.nickName;
    
    NSString *sexstr = @"";
    
    if (model.sex == 0) {
        sexstr = @"女";
    }else{
        sexstr = @"男";
    }
    NSString *ageStr = [NSString stringWithFormat:@"%ld",(long)model.age];
    self.sexAgehometownLab.text = [NSString stringWithFormat:@"%@, %@, %@",sexstr,ageStr,model.hometown];
    self.whyLab.text = model.deal;
    self.timeLab.text = model.createTime;
}

@end
